<script src="/js/laymi/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/js/layui/layui.js"></script>
<script type="text/javascript" src="/js/laymi/jquery-form.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.all.min.js"></script>
#--输入框--#
#define input(name,title,verify,value)
 <input type="text" name="#(name)"  #if(xKit.isNotBlank(value)) value="#(value)" #end   lay-verify="#(verify)" placeholder="请输入#(title)" autocomplete="off" class="layui-input">
#end
#--密码框--#
#define password(name,title,verify,value)
 <input type="password" name="#(name)"  #if(xKit.isNotBlank(value)) value="#(value)" #end   lay-verify="#(verify)" placeholder="请输入#(title)" autocomplete="off" class="layui-input">
#end
#--下拉选--#
#define select(name,title,table,code,text,extend,verify,value)
<select name="#(name)" lay-verify="#(verify)" lay-search>
  <option value="">选择#(title)可搜索</option>
  #for(x:xKit.getD(table,code,text,extend))
  <option value="#(xKit.getFirst(x)??)" #if(value==xKit.getFirst(x)) selected #end>#(xKit.getLast(x)??)</option>
  #end
</select>     
#end
#--复选框(默认风格)--#
#define checkbox_default(name,title,table,code,text,extend,verify,value)
  #for(x:xKit.getD(table,code,text,extend))
  <input name="#(name)" value="#(xKit.getFirst(x)??)" lay-verify="#(verify)" type="checkbox"  title="#(xKit.getLast(x)??)" #for(y:xKit.strs(value)) #if(y==xKit.getFirst(x)) checked #end #end >
  #end
#end
#--复选框(原始风格)--#
#define checkbox_primary(name,title,table,code,text,extend,verify,value)
  #for(x:xKit.getD(table,code,text,extend))
  <input name="#(name)" value="#(xKit.getFirst(x)??)" lay-verify="#(verify)" type="checkbox"  title="#(xKit.getLast(x)??)" lay-skin="primary" #for(y:xKit.strs(value)) #if(y==xKit.getFirst(x)) checked #end #end >
  #end
#end
#--开关--#
#define checkbox_switch(name,title,table,code,text,extend,verify,value)
  #for(x:xKit.getD(table,code,text,extend))
  <input name="#(name)" value="#(xKit.getFirst(x)??)" lay-verify="#(verify)" type="checkbox"  title="#(xKit.getLast(x)??)" lay-skin="switch" lay-text="开启|关闭" #for(y:xKit.strs(value)) #if(y==xKit.getFirst(x)) checked #end #end >
  #end
#end
#--单选框--#
#define radio(name,title,table,code,text,extend,verify,value)
  #for(x:xKit.getD(table,code,text,extend))
  <input type="radio" name="#(name)" lay-verify="#(verify)" value="#(xKit.getFirst(x)??)" title="#(xKit.getLast(x)??)" #if(value==xKit.getFirst(x)) checked #end>
  #end
#end
#--文本域--#
#define textarea(name,title,verify,value)
<textarea name="#(name)" required lay-verify="#(verify)" placeholder="请输入#(title)" class="layui-textarea">#if(xKit.isNotBlank(value))#(value)#end</textarea>
#end
#--laydate时间(YYYY-MM-DD hh:mm:ss)--#
#define laytime(name,title,verify,value)
<input class="layui-input" name="#(name)" lay-verify="#(verify)" placeholder="请输入#(title)" #if(xKit.isNotBlank(value)) value="#(value)" #end onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
});
</script>
#end
#--laydate日期(YYYY-MM-DD)--#
#define laydate(name,title,verify,value)
<input class="layui-input" name="#(name)" lay-verify="date|#(verify)" placeholder="请输入#(title)" #if(xKit.isNotBlank(value)) value="#(value)" #end onclick="layui.laydate({elem: this, festival: true})")">
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
});
</script>
#end
#--laydate日期limit(YYYY-MM-DD)--#
#define laydate_limit(name,title,verify,min,max,value)
<input class="layui-input" name="#(name)" lay-verify="date|#(verify)" placeholder="请输入#(title)" #if(xKit.isNotBlank(value)) value="#(value)" #end onclick="layui.laydate({elem: this, min: laydate.now(-#(min)), max: laydate.now(+#(max))})">
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
});
</script>
#end
#--laytime时间limit(YYYY-MM-DD)--#
#define laytime_limit(name,title,verify,min,max,value)
<input class="layui-input" name="#(name)" lay-verify="#(verify)" placeholder="请输入#(title)" #if(xKit.isNotBlank(value)) value="#(value)" #end onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss', min: laydate.now(-#(min)), max: laydate.now(+#(max))})">
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
});
</script>
#end
#--layedit编辑器--#
#define layedit(name,title,verify,value)
<textarea name="#(name)"  id="layedit" lay-verify="#(verify)"  style="display: none;">#if(xKit.isNotBlank(value))#(value)#end</textarea>
<div class="layui-word-aux"><blockquote class="layui-quote-nm"><b>提示:</b>请输入#(title)</blockquote></div>
<script>
layui.use('layedit', function(){
  var layedit = layui.layedit;
  layedit.set({
	  uploadImage: {
	    url: '/upload/layupload' //接口url
	    ,type: 'post' //默认post
	  }
	});
  layedit.build('layedit'); //建立编辑器
});
</script>
#end
#--umeditor编辑器--#
#define umeditor(name,title,verify,value)
<script id="umeditor" name="#(name)" type="text/plain">#if(xKit.isNotBlank(value))#(value)#end</script>
<script type="text/javascript" src="/js/ueditor/dialogs/xiumi-ue-dialog-v5.js"></script> 
<div class="layui-word-aux"><blockquote class="layui-quote-nm"><b>提示:</b>请输入#(title)。工具栏最后一个"X"图标打开有惊喜！</blockquote></div>
<script type="text/javascript">
	// 加载 ueditor，传入的初始化参数可以覆盖掉 ueditor.config.js 中的配置
	// 对于同一项目中使用不同的配置的 ueditor 场景非常有用
	var ue = UE.getEditor('umeditor', {
		initialFrameHeight:300
		//, initialFrameWidth:796
		,wordCount:false
	});

	// 由于ctrl+回车提交表单会让ajax form失效，所以让该快捷键失效
	// $(document).ready(function() {ue.shortcutkeys["autosubmit"] = "";});
	// 另一种让该表单提交快捷键失效的方法，注册同名plugin覆盖掉旧的，这种方式更加简单可靠
	UE.plugin.register('autosubmit',function(){});

	UE.plugin.register('jfajaxsubmit',function(){
		return {
			shortcutkey:{
				"jfajaxsubmit":"ctrl+13" // ctrl + 回车 提交表单
			},
			commands:{
				'jfajaxsubmit':{
					execCommand:function () {
						var me=this;
						if(me.fireEvent("beforesubmit")===false){
							return;
						}
						me.sync();
						$("#myArticleForm").submit();
					}
				}
			}
		}
	});
	ue.ready(function() {
		ue.execCommand('serverparam', {
			'uploadType': 'feedback'
		});
	});
</script>
#end
#--图片上传(ajax单张) --#
#define layupload(name,title,verify,value)
<div id="layer-photos#(name)">
    <input  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
    <img  id="LAY_upload#(name)" width="38px;"  height="38px;"  #if(xKit.isNotBlank(value)) layer-src="#(value)" src="#(value)"#end>
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layupload'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	LAY_upload#(name).src = res.url;
        	$("#layupload_input#(name)").val(res.url);    		
    	}else{
    		layer.msg(res.msg);    		
    	}
    }
  });
  $("#LAY_upload#(name)").click(function(){
		layer.photos({
			  photos: '#layer-photos#(name)'
			  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			});
  });
});
</script>
#end
#--图片上传(ajax多张) --#
#define layuploads(name,title,verify,value)
<div id="layer-photos#(name)">
    <input multiple="multiple"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value)) 
     <i class="img">
     <img  class="LAY_uploads" width="38px;"  height="38px;"   layer-src="#(y)" src="#(y)">&nbsp;
     </i>
     #end
     #end
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-photos#(name)").find(".img").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-photos#(name)").append('<img  class="LAY_uploads" width="38px;"  height="38px;"   layer-src="'+array[i]+'" src="'+array[i]+'">&nbsp; ');
    		}    		
    	}else{
    		layer.msg(res.msg);    		
    	}
    }
  });
});
$(function(){
	$("#layer-photos#(name)").on("click",".LAY_uploads",function(){
		layer.photos({
			  photos: '#layer-photos#(name)'
			  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			});
    });
});
</script>
#end
#--视频上传 --#
#define layuploadv(name,title,verify,value)
<div id="layer-v#(name)"  width="38px;"  height="38px;">
    <input  lay-ext="mp4" lay-type="video"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="vv">
     <button  value="v#(for.index)#(name)" class="layui-btn layui-btn-normal vb vv">#(title)#(for.count)</button>&nbsp;
     <div id="v#(for.index)#(name)" hidden="" class="vv">
     <video  width="100%;"  height="100%;" controls><source src="#(y)" type="video/mp4"></video>
     </div> 
     </i>
     #end
     #end
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传视频(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-v#(name)").find(".vv").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-v#(name)").append('<button  value="v'+i+'#(name)" class="layui-btn layui-btn-normal vb vv">#(title)'+(i+1)+'</button>&nbsp;<div id="v'+i+'#(name)" hidden="" class="vv"><video  width="100%;"  height="100%;" controls><source src="'+array[i]+'" type="video/mp4"></video></div>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
$(function(){
	var x =1;
	$("#layer-v#(name)").on("click",".vb",function(){
		if(x==2){
			layer.close(layer.index);
		}
		var $vb = $(this);
		layer.open({
			  type: 1,
			  shade: false,
			  area: ['420px', '240px'], //宽高
			  title: false, //不显示标题
			  content: $('#'+$vb.val()), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
			  cancel: function(){
				  x =1;
			  }
			});
		x=2;
		return false;
    });
});
</script>
#end
#--视频上传(ajax多视频) --#
#define layuploadvs(name,title,verify,value)
<div id="layer-vs#(name)"  width="38px;"  height="38px;">
    <input multiple="multiple" lay-ext="mp4" lay-type="video"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="vvs">
     <button  value="vs#(for.index)#(name)" class="layui-btn layui-btn-normal vb vvs">#(title)#(for.count)</button>&nbsp;
     <div id="vs#(for.index)#(name)" hidden="" class="vvs">
     <video  width="100%;"  height="100%;" controls><source src="#(y)" type="video/mp4"></video>
     </div> 
     </i>
     #end
     #end
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传视频(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-vs#(name)").find(".vvs").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-vs#(name)").append('<button  value="vs'+i+'#(name)" class="layui-btn layui-btn-normal vb vvs">#(title)'+(i+1)+'</button>&nbsp;<div id="vs'+i+'#(name)" hidden="" class="vvs"><video  width="100%;"  height="100%;" controls><source src="'+array[i]+'" type="video/mp4"></video></div>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
$(function(){
	var x =1;
	$("#layer-vs#(name)").on("click",".vb",function(){
		if(x==2){
			layer.close(layer.index);
		}
		var $vb = $(this);
		layer.open({
			  type: 1,
			  shade: false,
			  area: ['420px', '240px'], //宽高
			  title: false, //不显示标题
			  content: $('#'+$vb.val()), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
			  cancel: function(){
				  x =1;
			  }
			});
		x=2;
		return false;
    });
});
</script>
#end
#--音频上传--#
#define layuploadm(name,title,verify,value)
<div id="layer-m#(name)"  width="38px;"  height="38px;">
    <input  lay-ext="mp3|ogg" lay-type="audio"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="mm">
     <button  value="m#(for.index)#(name)" class="layui-btn layui-btn-normal mb mm">#(title)#(for.count)</button>&nbsp;
     <div id="m#(for.index)#(name)" hidden="" class="mm">
     <audio  src="#(y)" controls="controls"></audio>
     </div> 
     </i>
     #end
     #end
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传音频(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-m#(name)").find(".mm").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-m#(name)").append('<button  value="m'+i+'#(name)" class="layui-btn layui-btn-normal mb mm">#(title)'+(i+1)+'</button>&nbsp;<div id="m'+i+'#(name)" hidden="" class="mm"><audio  src="'+array[i]+'" controls="controls"></audio></div>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
$(function(){
	var x =1;
	$("#layer-m#(name)").on("click",".mb",function(){
		if(x==2){
			layer.close(layer.index);
		}
		var $mb = $(this);
		layer.open({
			  type: 1,
			  shade: false,
			  title: false, //不显示标题
			  content: $('#'+$mb.val()), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
			  cancel: function(){
				  x =1;
			  }
			});
		x=2;
		return false;
    });
});
</script>
#end
#--音频上传(ajax多音频) --#
#define layuploadms(name,title,verify,value)
<div id="layer-ms#(name)"  width="38px;"  height="38px;">
    <input multiple="multiple" lay-ext="mp3|ogg" lay-type="audio"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="mms">
     <button  value="ms#(for.index)#(name)" class="layui-btn layui-btn-normal mb mms">#(title)#(for.count)</button>&nbsp;
     <div id="ms#(for.index)#(name)" hidden="" class="mms">
     <audio  src="#(y)" controls="controls"></audio>
     </div>
     </i> 
     #end
     #end
</div>
<script>
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传音频(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-ms#(name)").find(".mms").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-ms#(name)").append('<button  value="ms'+i+'#(name)" class="layui-btn layui-btn-normal mb mms">#(title)'+(i+1)+'</button>&nbsp;<div id="ms'+i+'#(name)" hidden="" class="mms"><audio  src="'+array[i]+'" controls="controls"></audio></div>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
$(function(){
	var x =1;
	$("#layer-ms#(name)").on("click",".mb",function(){
		if(x==2){
			layer.close(layer.index);
		}
		var $mb = $(this);
		layer.open({
			  type: 1,
			  shade: false,
			  title: false, //不显示标题
			  content: $('#'+$mb.val()), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
			  cancel: function(){
				  x =1;
			  }
			});
		x=2;
		return false;
    });
});
</script>
#end
#--文件上传 --#
#define layuploadf(name,title,verify,value)
<div id="layer-f#(name)"  width="38px;"  height="38px;">
    <input  lay-type="file"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="ff">
     <a href="#(y)" class="layui-btn  layui-btn-normal ff" download="#(title)#(for.count)#(xKit.suffix(y))">#(title)#(for.count)</a>&nbsp;
     </i>
     #end
     #end
</div>
<script>
function suffix(str){
	var suffix=str.substring(str.lastIndexOf("."));//后缀名
	return suffix;
   }
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传文件(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-f#(name)").find(".ff").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-f#(name)").append('<i class="ff"><a href="'+array[i]+'" class="layui-btn  layui-btn-normal ff" download="#(title)'+(i+1)+suffix(array[i].trim())+'">#(title)'+(i+1)+'</a>&nbsp;</i>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
</script>
#end
#--文件上传(ajax多文件) --#
#define layuploadfs(name,title,verify,value)
<div id="layer-fs#(name)"  width="38px;"  height="38px;">
    <input multiple="multiple"  lay-type="file"  name="file" class="layui-upload-file" id="layupload#(name)" type="file" >
    <input id="layupload_input#(name)"  name="#(name)" lay-verify="#(verify)"  type="text" value="#(value)" hidden=""/>
     #if(xKit.isNotBlank(value))
     #for(y:xKit.strs(value))
     <i class="ffs">
     <a href="#(y)" class="layui-btn  layui-btn-normal ffs" download="#(title)#(for.count)#(xKit.suffix(y))">#(title)#(for.count)</a>&nbsp;
     </i>
     #end
     #end
</div>
<script>
function suffix(str){
	var suffix=str.substring(str.lastIndexOf("."));//后缀名
	return suffix;
   }
layui.use(['upload','layer'], function(){
	var layer = layui.layer;
  layui.upload({
    url: '/upload/layuploads'
    ,title: '上传文件(10M)'
    ,elem: '#layupload#(name)' //指定原始元素，默认直接查找class="layui-upload-file"
    ,method: 'post' //上传接口的http类型
    ,success: function(res){
    	if(res.s=='0'){
        	$("#layer-fs#(name)").find(".ffs").remove();
        	$("#layupload_input#(name)").val(res.url);
        	var array =res.url.split(",")
        	for (var i = 0; i < array.length; i++) {
        		$("#layer-fs#(name)").append('<i class="ffs"><a href="'+array[i]+'" class="layui-btn  layui-btn-normal ffs" download="#(title)'+(i+1)+suffix(array[i].trim())+'">#(title)'+(i+1)+'</a>&nbsp;</i>');
    		}	
    	}else{
    		layer.msg(res.msg);
    	}
    }
  });
});
</script>
#end